package utils;

//import EnvObjects.myVector;

public class myVector {
	public float x = 1;
	public float y = 0;
	
	public myVector(myVector anotherVec){
		x = anotherVec.x;
		y = anotherVec.y;
	}
	
	public myVector(float _x, float _y){
		x=_x;
		y=_y;
	}
	
	public myVector(){
		x = 1;
		y = 0;
	}
	
	public void setVector(float _x, float _y){
		x = _x;
		y = _y;
	}
	public void setVector(myVector anotherVec){
		x = anotherVec.x;
		y = anotherVec.y;
	}
	
	public float dotProduct(myVector anotherVec){
		return x*anotherVec.x + y*anotherVec.y;
	}
	
	public myVector getDirectionTo(myVector anotherVec) {
		return anotherVec.subtract(this);
	}
	
	public myVector add(myVector anotherVec) {
		return new myVector(x+anotherVec.x, y+anotherVec.y);
	}
	
	public myVector subtract(myVector anotherVec){
		return new myVector(x-anotherVec.x, y-anotherVec.y);
	}
	
	public myVector multiplyByConst(float aConstant) {
		return new myVector(x * aConstant, y * aConstant);
	}
	
	public float length() {
		return (float)Math.sqrt((double)(x * x + y * y));
	}
	
	public float distanceTo(myVector anotherVec) {
		return (float)Math.sqrt((double)(x - anotherVec.x) * (x - anotherVec.x) + (y - anotherVec.y) * (y - anotherVec.y));
	}
	
	public void normalize() {
		float length = length();
		
		if(length>0.01f) {
			x /= length;
			y /= length;
		}
	}


}
